<template>
  <div>
    <el-button type="primary" @click="fetchData">获取数据</el-button>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column width="200" prop="id" label="ID"></el-table-column>
      <el-table-column
        width="400"
        prop="userName"
        label="用户名"
      ></el-table-column>
      <el-table-column
        width="400"
        prop="password"
        label="密码"
      ></el-table-column>
      <el-table-column
        width="300"
        prop="createTime"
        label="创建时间"
      ></el-table-column>
      <el-table-column
        width="300"
        prop="updateTime"
        label="更新时间"
      ></el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { ElButton, ElTable } from "element-plus";
import axios from "axios";

const tableData = ref([]);

const fetchData = async () => {
  try {
    const response = await axios.get("http://localhost:808/user/getPageList");
    //console.log(response.data.data.records)
    tableData.value = response.data.data.records;
  } catch (error) {
    console.error("An error occurred while fetching data:", error);
  }
};
</script>

<style>
/* 添加样式 */
</style>
